package com.cn.wanxi.servlet.back.user;

import com.cn.wanxi.model.UserModel;
import com.cn.wanxi.service.IUserService;
import com.cn.wanxi.service.impl.UserServiceImpl;
import com.mysql.cj.xdevapi.JsonArray;
import net.sf.json.JSON;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/UserFindByUserIdServlet")
public class UserFindByUserIdServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        IUserService iUserService = new UserServiceImpl();
        UserModel userModel = iUserService.findByUserId(Integer.parseInt(id));
        JSONArray jsonArray= JSONArray.fromObject(userModel);
        resp.getWriter().println(jsonArray);
    }
}
